<template>
  <SelectCom :table="dataInfo" title="工艺" @searchBtn="getTbody" @selectBtn="selectBtn" isCheckbox>
    <template #search="{ search }">
      <ElFormItemBox label="工艺名称" prop="likeWords">
        <ElInputBox :data="search" dataName="likeWords" />
      </ElFormItemBox>
    </template>
    <el-button type="primary">选择工艺</el-button>
  </SelectCom>
</template>
<script setup lang="ts">
import { onMounted, getCurrentInstance, onUnmounted } from 'vue';
const { proxy } = getCurrentInstance() as any;
const props = withDefaults(
  defineProps<{
    data?: any
  }>(),
  {

  },
);
const dataInfo: any = reactive({
  title: '工艺列表',
  rowKey: 'code',
  tbody: [],
  theadCode: '',
  selectable: (row: any) => {
    let _arr = props.data.table.tbody.map((el: any) => el.craftCode)
    return !_arr.includes(row.code)
  },
  thead: [
    {
      label: '工艺编号',
      prop: 'code',
      hidden: false,
      align: 'left',
      tooltip: false,
      width: 100,
      fixed: false,
    },
    {
      label: '工艺名称',
      prop: 'name',
      hidden: false,
      align: 'left',
      tooltip: false,
      width: null,
      fixed: false,
    },
    {
      label: '备注',
      prop: 'remarks',
      hidden: false,
      align: 'left',
      tooltip: false,
      width: null,
      fixed: false,
    },
  ],
  //表格-搜索数据
  search: {
    likeWords: '',
  },
})
const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'selectBtn', arr: any): void;
}>();
const selectBtn = (arr: any) => {
  emit('selectBtn', arr);
}
const getTbody = () => {
  proxy.$api.ProductCraft.GetMatchProductCrafts(dataInfo.search)
    .then((res: any) => {
      dataInfo.tbody = res;
    })
    .catch(() => { });
}
onMounted(() => {

});
onUnmounted(() => { });
</script>
<style scoped lang="scss"></style>
